package dabs.engine;


public class GameEngine implements Runnable {
	private boolean stopped = false;
	private int changing = 0;
	private Environment environment;
	private PostOffice poffice;
	public PowerPlant powerPlant; //public just for testing

	// public API
	public PostOffice getPostOffice()  { return poffice; }
	public Environment getEnvironment() { return environment; }
	/* TODO
	 * public runCommand(GameCommand command) {;}
	 */
	
	public int getValue() { return changing; }

	public void stop() { stopped = true; }

	public GameEngine() {
		poffice = new PostOffice();
		environment = new Environment(this, 60);
		powerPlant = new PowerPlant(this);
	}

	public void run() {
		while(!stopped) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				System.out.println("Interrupted engine... bad");
			}
			changing++;
			environment.tick();
			powerPlant.tick();
		}
	}
	
	
}

